using Microsoft.EntityFrameworkCore;
using MyWebApi.Domian;

// var builder = WebApplication.CreateBuilder(args);
// var conntionString = builder.configuration.GetConnctionString("mysql");
// builder.Services.AddDbContext<StudentDbContext>(s =>
// {
//     s.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
// }
// );
// // 添加控制
// builder.Services.AddControllers();

// var app = builder.Build();
// // 注册泛型

// // builder.Services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));
// app.MapControllers();




// app.Run();


var builder = WebApplication.CreateBuilder(args);

// 配置数据库上下文
var connectionString = builder.Configuration.GetConnectionString("mysql");
//添加上下文
builder.Services.AddDbContext<StudentDbContext>(s =>
{
    s.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
});

// 添加控制器服务
builder.Services.AddControllers();

// 注册泛型仓储
// builder.Services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));

var app = builder.Build();

// 将控制器中的 API 注册到路由
app.MapControllers();

app.Run();